<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>Action JSP</title>
	<style type="text/css">
		a.productLink {
			color: red;
			font-family: Monaco;
			font-size: 15px;
			font-stretch: wider;
		}
	</style>
</head>

<body style="text-align:center;">
	<jsp:useBean id="product1" class="pony.model.Product" />
	<jsp:useBean id="product2" class="pony.model.Product" />
	<jsp:useBean id="product3" class="pony.model.Product" />
	<jsp:useBean id="product4" class="pony.model.Product" />
	
	<!-- 小心，如果使用 Scriptlet取得請求參數，回傳值型別是 String，要自行強制轉型! -->
	<% product1.setName(request.getParameterValues("name")[0]); %>
	<% product1.setPrice( Double.parseDouble(request.getParameterValues("price")[0]) ); %>
	
	<jsp:setProperty name="product2" property="name" value="${paramValues.name[1] }" />
	<jsp:setProperty name="product2" property="price" value="${paramValues.price[1] }" /> 
	<!-- 如果使用JSP standard action標籤，Container會自動幫我們轉型! -->
	
	<jsp:setProperty name="product3" property="name" 
			value='<%= request.getParameterValues("name")[2] %>' />
	<jsp:setProperty name="product3" property="price" 
			value='<%= Double.parseDouble( request.getParameterValues("price")[2] ) %>' />
	<!-- 小心，如果使用 JSP運算式 Request-time Attribute 設定特性值，也要自行轉型! -->
		
	<jsp:setProperty name="product4" property="name" value="${paramValues['name'][3] }" />
	<jsp:setProperty name="product4" property="price" value="${paramValues['price'][3] }" />
	
	<p>
		no.1 product's name is :<b><em>${pageScope.product1["name"] }</em></b><br />
		no.1 product's price is :<b><em>${pageScope.product1["price"] }</em></b><br />
		<a class="productLink" href="productBass.do">more info about ${product1.name }</a>
	</p>
	<p>
		no.2 product's name is :<b><em>${pageScope.product2.name }</em></b><br />
		no.2 product's price is :<b><em>${pageScope.product2.price }</em></b><br />
		<a class="productLink" href="productGuitar.do">more info about ${product2.name }</a>
	</p>
	<p>
		no.3 product's name is :<b><em>${pageScope.product3.name }</em></b><br />
		no.3 product's price is :<b><em>${pageScope.product3.price }</em></b><br />
		<a class="productLink" href="productPiano.do">more info about ${product3.name }</a>
	</p>
	<p>
		no.4 product's name is :<b><em>${product4['name'] }</em></b><br />
		no.4 product's price is :<b><em>${product4['price'] }</em></b><br />
		<a class="productLink" href="productDrums.do">more info about ${product4.name }</a>
	</p>
</body>
</html>